package com.atguigu.daijia.driver.config;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 创建微信工具包对象WxMaService
 */
@Configuration
public class WxConfigOperator {

    @Autowired
    private WxConifgProperties wxConifgProperties;

    @Bean
    public WxMaService wxMaService(){
        //注入appid和secret
        WxMaDefaultConfigImpl wxMaDefaultConfig = new WxMaDefaultConfigImpl();
        wxMaDefaultConfig.setAppid(wxConifgProperties.getAppId());
        wxMaDefaultConfig.setSecret(wxConifgProperties.getSecret());
        WxMaServiceImpl service = new WxMaServiceImpl();
        service.setWxMaConfig(wxMaDefaultConfig);
        return service;
    }
}
